package com.by;
import com.by.aop.LoggingInterceptor;
import com.by.aop.MethodInterceptor;
import com.by.application.AnnotationConfigApplicationContext;
import com.by.app.UserService;
import com.by.proxy.ProxyFactory;
public class Main {
    public static void main(String[] args) throws Exception {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("com.by.app");
        UserService userService = (UserService) context.getBean("UserServiceImpl");
        //创建拦截器
        MethodInterceptor methodInterceptor=new LoggingInterceptor();
        //创建代理工厂
        ProxyFactory proxyFactory=new ProxyFactory(userService,methodInterceptor);
        UserService proxy = (UserService) proxyFactory.getProxy();
        proxy.addUser();
    }
}
